package com.koron.order.risk.riskDuty.controller;


import com.koron.bean.base.Response;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.risk.riskDuty.bean.dto.LineRiskDutyPathDTO;
import com.koron.order.risk.riskDuty.bean.po.LineRiskDutyPath;
import com.koron.order.risk.riskDuty.bean.query.LineRiskDutyPathQuery;
import com.koron.order.risk.riskDuty.service.LineRiskDutyPathService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 看护值守巡视路线信息(LineRiskDutyPath)表控制层
 *
 * @author jzp
 * @since 2022-12-28 17:03:12
 */
@Api(tags = "风险看护值守单-巡视路线信息接口")
@RestController
@RequestMapping("lineRiskDutyPath")
public class LineRiskDutyPathController {
    /**
     * 服务对象
     */
    @Autowired
    private LineRiskDutyPathService lineRiskDutyPathService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation(value = "根据id查询")
    @GetMapping
    public Response<LineRiskDutyPathDTO> selectOne(@RequestParam String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), lineRiskDutyPathService, "getDtoById", LineRiskDutyPathDTO.class, id));
    }

    @ApiOperation(value = "列表查询")
    @GetMapping("list")
    public Response<List<LineRiskDutyPath>> list(LineRiskDutyPathQuery query) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), lineRiskDutyPathService, "list", List.class, query));
    }

    @ApiOperation(value = "保存")
    @PostMapping("save")
    public Response<LineRiskDutyPathDTO> save(@RequestBody LineRiskDutyPathDTO lineRiskDutyPathDTO) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), lineRiskDutyPathService, "saveDto", LineRiskDutyPathDTO.class, lineRiskDutyPathDTO));
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("delete")
    public Response delete(@RequestParam String id) {
        ADOConnection.runTask(getCurrDs(), lineRiskDutyPathService, "deleteById", Boolean.class, id);
        return Response.ok();
    }
}

